      SUBROUTINE SOLGEN(KCOORD,TSEC50,RSUN,IFLAG)
      IMPLICIT REAL*8(A-H,O-Z)
C
C CALCULATE THE POSITION OF THE SUN IN A SPECIFIED COORDINATE SYSTEM
C
C VARIABLE TYPE I/O DESCRIPTION
C -------- ---- --- -----------
C
C KCOORD   I*4   I  FLAG IDICATING WHICH COORDINATE SYSTEM IS WANTED.
C
C                   = 1, GEOCENTRIC, MEAN EQUATOR AND EQUINOX OF 1950.0
C                   = 2, GEOCENTRIC, MEAN EQUATOR AND EQUINOX OF DATE
C                   = 3, GEOCENTRIC, TRUE EQUATOR AND EQUINOX OF DATE
C                   = OTHERWISE, ERROR. AUTOMATIC STOP IN THIS ROUTINE.
C
C TSEC50   R*8   I  INPUT TIME IN SECONDS SINCE 1/1/50, 0.0 HOURS ET.
C                   MAY BE ANY VALUE, + OR -. ACCURACY IS NOT HIGH
C                   ENOUGH TO WARRANT AN ET-UT CORRECTION, SO TIME CAN
C                   BE UT IF IT IS MORE CONVENIENT.
C
C RSUN(3)  R*8   O  CARTESIAN VECTOR TO THE SUN FOR THAT TIME
C
C IFLAG    I*4   I  = 1, RSUN IS TO BE A UNIT VECTOR
C                   = OTHERWISE, RSUN IS TO BE A POSITION VECTOR. IN KM.
C
C***********************************************************************
C
C BY C PETRUZZO, 5/85.
C  MODIFIED....
C
C***********************************************************************
C
      REAL*8 RSUN(3)
C
      IF(KCOORD.EQ.1) THEN
        CALL SOLM50(TSEC50,RSUN,IFLAG)
C
      ELSE IF(KCOORD.EQ.2) THEN
        CALL SOLMDT(TSEC50,RSUN,IFLAG)
C
      ELSE IF(KCOORD.EQ.3) THEN
        CALL SOLTOD(TSEC50,RSUN,IFLAG)
C
      ELSE
        STOP ' ERROR END IN SOLGEN. BAD COORDINATE SYSTEM FLAG.'
        END IF
C
      RETURN
      END
